<!doctype html>
<html class="x-admin-sm">
<head>
    <title>后台登录-X-admin2.2</title>
    <link rel="stylesheet" href="/assets/css/login.css">
    <script th:replace="~{layout/common-head :: head}"></script>
</head>
<body class="login-bg">

<div class="login layui-anim layui-anim-up">
    <div class="message">x-admin2.0-管理登录</div>
    <div id="darkbannerwrap"></div>
    <div class="layui-form">
        <input name="username" placeholder="用户名" value="123" type="text" lay-verify="required" class="layui-input">
        <hr class="hr15">
        <input name="password" lay-verify="required" placeholder="密码" value="123" type="password" class="layui-input">
        <hr class="hr15">
        <button style="width: 100%" class="layui-btn" lay-submit lay-filter="login">登 录</button>
        <hr class="hr20">
    </div>
</div>

<script>
    layui.use(['form', 'jquery', 'layer'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        var layer = layui.layer;
        // layer.msg('玩命卖萌中', function(){
        //   //关闭后的操作
        //   });
        //监听提交
        form.on('submit(login)', function (data) {
            // alert(888)
            // layer.msg(JSON.stringify(data.field), function () {
            //     location.href = 'index.html'
            // });
            data = data.field
            $.ajax({
                data: {'username': data.username, 'password': data.password},
                url: '/login',
                type: 'post',
                success(data) {
                    layer.msg(data.msg)
                    if (data.code == 0) {
                        setTimeout(function () {
                            window.location.href = data.data + ""
                        }, 1000)
                    }
                }
            })
            return false;
        });
    });

</script>
</body>
</html>